package com.example.houduan.controller;
import com.example.houduan.domain.F_sb;
import com.example.houduan.domain.Jy_sb;
import com.example.houduan.domain.Self_sb;
import com.example.houduan.domain.Yj_table;
import com.example.houduan.rep.Replogin;
import com.example.houduan.rep.Repwzsf;
import com.example.houduan.resp.CommonResp;
import com.example.houduan.resp.Resplogin;
import com.example.houduan.service.*;
import org.springframework.util.ObjectUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;


@RestController
public class Test {
    @Resource
    private Wordservice wordservice;
    @Resource
    private Userservice userservice;
    @Resource
    private Wzsbservice wzsbservice;
    @Resource
    private Zzsbservice zzsbservice;
    @Resource
    private Lfdjservice lfdjservice;
    @Resource
    private Yjfkservice yjfkservice;
    @Resource
    private Jydjservice jydjservice;
    //返回列表
    @GetMapping("/wordlist")
    public CommonResp reword(){
        return wordservice.list();
    }
    //查找文章
    @GetMapping("/fword")
    public CommonResp fword(int id){
        return wordservice.find(id);
    }
    //登录
    @PostMapping("/login")
    public CommonResp login(@RequestBody Replogin replogin)
    {
        CommonResp<Resplogin> resp = new CommonResp<>();
        Resplogin resplogin=userservice.login(replogin);
        if (ObjectUtils.isEmpty(resplogin)) {
            resp.setSuccess(false);
            return resp;
        } else {
            resp.setContent(resplogin);
            return resp;
        }
    }
    //自主省报
    @PostMapping("/addzzsb")
    public CommonResp addzzsb(@RequestBody Self_sb self_sb)
    {
        return zzsbservice.add(self_sb);
    }
    //查找自主申报
    @GetMapping("/fzzsb")
    public CommonResp fzzsb(String uid){
        return zzsbservice.listall(uid);
    }
    //来访登记
    @PostMapping("/addlfdj")
    public CommonResp addlfdj(@RequestBody F_sb f_sb){
        return lfdjservice.add(f_sb);
    }
    //来访记录查询
    @GetMapping("/flfdj")
    public CommonResp flfdj(String uid)
    {
        return lfdjservice.listall(uid);
    }
    //添加物资
    @PostMapping("/addwzsb")
    public CommonResp addwzsb(@RequestBody Repwzsf repwzsf)
    {
        return wzsbservice.add(repwzsf);
    }
    //查询物资，有答复 完成申报
    @GetMapping("/fwwzcb")
    public CommonResp fwwzcb(String uid){
        return wzsbservice.fwwzsb(uid);
    }
    //查询物资，无答复 申报种
    @GetMapping("/fzwzcb")
    public CommonResp fzwzcb(String uid){
        return wzsbservice.fzwzsb(uid);
    }
    //意见反馈
    @PostMapping("/addyjfk")
    public CommonResp addyjfk(@RequestBody Yj_table yj_table)
    {
        return yjfkservice.add(yj_table);
    }
    @GetMapping("/fzyj")
    public CommonResp fzyj(String uid)
    {
        return  yjfkservice.fzyj(uid);
    }
    @GetMapping("/fwyj")
    public CommonResp fwyj(String uid)
    {
        return  yjfkservice.fwyj(uid);
    }
    @PostMapping("/addjysb")
    public CommonResp addjysb(@RequestBody Jy_sb jy_sb)
    {
        return  jydjservice.add(jy_sb);
    }
    @GetMapping("/zjysb")
    public CommonResp zjysb(String uid)
    {
        return  jydjservice.jysbz(uid);
    }
    @GetMapping("/wjysb")
    public CommonResp wjysb(String uid)
    {
        return  jydjservice.jysbw(uid);
    }

}
